package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.common.utils.AliOssUtil;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Set;
import java.util.UUID;

@RestController
@RequestMapping("/setmeal")
@Api(tags = "用户端套餐相关接口")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    @Autowired
    private AliOssUtil util;
    @Qualifier("redisTemplate")
    @Autowired
    private RedisTemplate redisTemplate;



    /**
     * 获取所有套餐信息
     * @return
     */
    @PostMapping("/getSetmeal")
    @ApiOperation("获取所有套餐信息")
    public Result getSetmeal(){
        log.info("获取所有套餐数据");
        List<Setmeal> list = setmealService.getSetmeal();
        return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,list);
    }

    /**
     * 根据id查询套餐详情
     * @param id
     * @return
     */
    @PostMapping("findById")
    @ApiOperation("根据id查询套餐详情")
    public Result findSetmealById(Integer id){
        log.info("根据id查询套餐详情");
        Setmeal result = setmealService.findById(id);
        return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,result);
    }
}
